import {createAsyncThunk, createSlice} from "@reduxjs/toolkit";
import {getHomeGoodPriceData} from "../../services/modules/home";

export const homeThreeThunk = createAsyncThunk('homeThreeThunk', async (dispatch, getState) => {
    return await getHomeGoodPriceData()
})

const homeThreeStore = createSlice({
    name: "homeThree",
    initialState: {
        list: [],
        data: {},
        count: 0,
    },
    reducers: {
        changeHomeDataList : (state, action) => {
            state.list = action.payload
        },
        incr: (state, action) => {
            state.count += 1
        }
    },

    extraReducers: (builder) => {
        builder.addCase(homeThreeThunk.fulfilled, (state, action) => {
            state.data = action.payload;
        })
    }
});

export const {changeHomeDataList, incr} = homeThreeStore.actions;
export default homeThreeStore.reducer